package ai.people.netmon.framework.domain.archives.vo;

import ai.people.netmon.framework.domain.archives.entity.GangGroupMembersGraphBO;
import ai.people.netmon.framework.domain.archives.entity.GangGroupOrgPersonListBO;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.ToStringSerializer;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.Date;
import java.util.List;

/**
 * @author zhenglin
 * @date 2022/6/21
 */
@Data
@NoArgsConstructor
public class GangGroupOrgPersonListVO {

    /**
     * 档案id
     */
    @JSONField(serializeUsing = ToStringSerializer.class)
    private Long archivesId;
    /**
     * 图片
     */
    private String picture;
    /**
     * 姓名
     */
    private String name;
    /**
     * 创建者账号
     */
    private String creatorName;
    /**
     * 信息
     */
    private String info;
    /**
     * 团伙身份
     */
    private String groupIdentity;
    /**
     * 危险程度
     */
    @JSONField(serializeUsing = ToStringSerializer.class)
    private Integer degreeOfDanger;
    /**
     * 标签
     */
    private List<String> tags;
    /**
     * 社交信息
     */
    private List<Social> socials;
    /**
     * 身份证
     *
     */
    private String idNumber;
    /**
     * 手机号
     */
    private List<String> phoneNumber;

    /**
     * 图更新时间
     */
    private Long graphUpdateTime;

    /**
     * 档案更新时间
     */
    private Date archivesUpdateTime;

    public GangGroupOrgPersonListVO(GangGroupMembersGraphBO node, GangGroupOrgPersonListBO gangGroupOrgPersonListBO, String creatorName) {
        this.archivesId = gangGroupOrgPersonListBO.getId();
        this.picture = gangGroupOrgPersonListBO.getPicture();
        this.name = gangGroupOrgPersonListBO.buildNameFirst();
        this.creatorName = creatorName;
        List<Social> socialList = gangGroupOrgPersonListBO.buildSocials();
        String buildInfo = gangGroupOrgPersonListBO.buildInfo();
        if (StringUtils.isBlank(buildInfo) && socialList.size() > 0) {
            buildInfo = socialList.get(0).getBrief();
        }
        this.info = buildInfo;
        this.groupIdentity = node.getGroupIdentity();
        this.degreeOfDanger = node.getDegreeOfDanger() == null ? null : Integer.parseInt(node.getDegreeOfDanger());
        this.tags = gangGroupOrgPersonListBO.buildTagsList();
        this.socials = socialList;
        this.idNumber = gangGroupOrgPersonListBO.getIdNumber();
        this.phoneNumber = gangGroupOrgPersonListBO.buildPhoneNumberList();
        this.graphUpdateTime = node.getUpdateTime();
        this.archivesUpdateTime = gangGroupOrgPersonListBO.getUpdateTime();
    }

    @Data
    public static class Social {
        /**
         * 平台
         */
        private String socialPlatform;
        /**
         * 账号
         */
        private String username;
        /**
         * 简介
         */
        private String brief;
    }

}
